﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LitJson;

public partial class Test_Scripts_Information_NexusOne : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("2. Getting information about: Google-Nexus one");
        HDAPI.HDBase hd = new HDAPI.HDBase(Request);
        if (hd.information("Google", "Nexus One"))
        {
            JsonData data = hd.getInformation();
            foreach (System.Collections.Generic.KeyValuePair<string, JsonData> o in data)
            {
                Append(InfoType.Success,o.Key + ":" + o.Value.ToJson() + "<br>");
            }
            Append(InfoType.Success, "API call successful.");
            Session["2"] = "<font color='green'>API call successful.</font>";
        }
        else
        {
            Append(InfoType.Error,hd.getError());
            Session["2"] = "<font color='red'>" + hd.getError() + "</font>";
        }
    }
    public void Append(InfoType tp, string information)
    {
        string color = "Green";
        if (tp == InfoType.Error)
        {
            color = "Red";
        }
        lblMessage.Text += "<font color='" + color + "'>" + information + "</font><br/>";
    }
    public enum InfoType
    {
        Error = 0,
        Success = 1
    }
}
